package com.etc.controller;

import com.etc.entity.RoomType;
import com.etc.service.RoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;

@Controller
@RequestMapping("/frontController")
public class FrontController {
    @Autowired
    RoomTypeService rtService;

    @RequestMapping("/userCenter")
    public ModelAndView userCenter(){
        ModelAndView mv=new ModelAndView();
        mv.setViewName("userCenter");
        return mv;
    }

    @RequestMapping("/allRoom")
    public ModelAndView allRoom(){
        ModelAndView mv=new ModelAndView();
        mv.setViewName("room");
        return mv;
    }

    @RequestMapping("/roomSingle")
    public ModelAndView roomSingle(@RequestParam(value = "rtName",defaultValue = "单人房") String rtName){
        RoomType roomType = rtService.queryRoomTypeByRtname(rtName);
        ModelAndView mv=new ModelAndView();
        mv.addObject("roomType",roomType);
        mv.setViewName("room-single");
        return mv;
    }

    @RequestMapping("/service")
    public ModelAndView service(){
        ModelAndView mv=new ModelAndView();
        mv.setViewName("service");
        return mv;
    }

    @RequestMapping("/checkinDate")
    public ModelAndView checkinDate(String begin,String end,String people,String child){
        ModelMap map = new ModelMap();
        map.put("begin",begin);
        map.put("end",end);
        map.put("people",people);
        map.put("child",child);
        ModelAndView mv=new ModelAndView();
        mv.addAllObjects(map);
        mv.setViewName("room");
        return mv;
    }

}
